#!/bin/sh

# set lib path
LD_LIBRARY_PATH="/lib:/usr/lib:/usr/local/lib:/app/lib"
export LD_LIBRARY_PATH

#set core dump parameter
ulimit -c unlimited

#load ko
cd /app/komod
./load_module

#set fflush data level
echo 20 > /proc/sys/vm/dirty_background_ratio
echo 40 > /proc/sys/vm/dirty_ratio
echo 2048 > /proc/sys/vm/min_free_kbytes
echo 1024 > /proc/sys/vm/user_reserve_kbytes


#start application
cd /app/bin
./main_app &
/app/debug_coredump &

# set network and start telnetd
if [ -f "/app/network_telnetd.sh" ];then
	cd /app
	./network_telnetd.sh
fi

# start ci agent
if [ -f "/app/start_agent.sh" ];then
	cd /app
	./start_agent.sh
fi
